﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Ink;

namespace ThePresenter.Net.PresenterCom.Uids
{
	[Serializable]
	class UidCollection : List<Uid>
	{
		public UidCollection(StrokeCollection Strokes)
		{
			foreach (Stroke S in Strokes)
			{
				this.Add(S.GetUid());
			}
		}

		public StrokeCollection FilterStrokes(Dictionary<Uid, Stroke> StrokesToSelectFrom)
		{
			StrokeCollection Selection = new StrokeCollection();

#if DEBUG
			int i = 0;
#endif
			foreach (Uid U in this)
			{
				if (StrokesToSelectFrom.ContainsKey(U))
				{
					Selection.Add(StrokesToSelectFrom[U]);
				}
#if DEBUG
				else
				{
					i++;
				}
#endif
			}

#if DEBUG
			if (i > 0)
			{
				MessageBox.Show(String.Format("Could not find {0} of {1} strokes to modify. This could mean server and client are out of sync or that client deleted strokes created by server.", i, this.Count), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
			}
#endif

			return Selection;		
		}
	}
}
